import java.util.Timer;
import java.util.TimerTask;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-09-19
 * Time:20:56
 */
public class Timer1 {
    public static void main(String[] args) {
        //标准的定时器
        //一个定时器可以同时安排多个任务
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("定时器开始1!");
            }
        },3000);
        Timer timer2 = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("定时器开始2!");
            }
        },4000);
        Timer timer3 = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("定时器开始3!");
            }
        },5000);
        System.out.println("开始计时");
    }
}
